/**
 */

package test;

import org.junit.Test;
import com.bei_en.common.util.SMS.ali.SMS;
import com.bei_en.common.util.SMS.ali.SmsRespFail;
import com.google.gson.Gson;
import com.taobao.api.ApiException;
import com.taobao.api.Constants;
import com.taobao.api.DefaultTaobaoClient;
import com.taobao.api.request.AlibabaAliqinFcSmsNumSendRequest;
import com.taobao.api.response.AlibabaAliqinFcSmsNumSendResponse;

/**
 * @author Guocg
 *
 */
public class testSms {

	// @Test
	public void sdf() {

		DefaultTaobaoClient client = new DefaultTaobaoClient(
				"http://gw.api.taobao.com/router/rest", "23312612",
				"99c167a78da5cb5b8300e0442c54fe22", Constants.FORMAT_JSON,
				30000, 60000);
		client.setUseSimplifyJson(true);
		AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
		// req.setExtend("sdf");
		req.setSmsType("normal");
		req.setSmsFreeSignName("身份验证");
		req.setSmsParamString("{\"code\":\"345345\",\"product\":\"\\\"车知道\\\"\"} ");
		req.setRecNum("17776206451");
		req.setSmsTemplateCode("SMS_5078325");
		AlibabaAliqinFcSmsNumSendResponse rsp = new AlibabaAliqinFcSmsNumSendResponse();
		try {
			rsp = client.execute(req);
		} catch (ApiException e) {
			e.printStackTrace();
		}
		String body = rsp.getBody();
		System.out.println(body);
		if (body.startsWith("{\"error")) {
			SmsRespFail resp = new Gson().fromJson(body, SmsRespFail.class);
			System.out.println(resp.getError_response().getMsg() + ":"
					+ resp.getError_response().getSub_msg());
		}
	}

	@Test
	public void fdg() {

		System.out.println(SMS.sendVerifyCode("17776206451,15263066451",
				"654654"));
	}
}
